<template>
  <div id="app">
      <div class="item" v-for="item of list" :key="item.id" @click="handleClick(item.id)">
          <img :src="item.coverImgUrl" alt="">
          <p>{{item.name}}</p>
      </div>
  </div>
</template>

<script>
import axios from 'axios';
export default {
    name:'App',
    data(){
        return{
            list:[]
        }
    },
    mounted(){
        axios.get("http://47.108.197.28:3000/top/playlist").then(res=>{
            this.list = res.data.playlists
        })
    },
    methods:{
        handleClick(id){
            console.log(id);
            this.$router.push(`/detail?id=${id}`)
        }
    }
}
</script>

<style scoped>
    #app{
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
    }
    .item{
        width: 150px;
        
    }
    img{
        width: 150px;
    }
</style>